libname cam "\\casd.fr\casdfs\Projets\INEPROG\Data\CAM_CAM_2011";

data cam0; set cam.camindivdiff; 
	* extern_a=(s2q1=1 and s2q3 NE 1);
	extern=(S2Q2_l1c1=1 | S2Q2_l2c1=1 | S2Q2_l3c1=1 | S2Q2_l4c1=1 | S2Q2_l5c1=1 | S2Q2_l6c1=1 | S2Q2_l7c1=1);
	deloc_b=(S2Q2_l1c2=1 | S2Q2_l2c2=1 | S2Q2_l3c2=1 | S2Q2_l4c2=1 | S2Q2_l5c2=1 | S2Q2_l6c2=1 | S2Q2_l7c2=1);
	firm=siren;
	job_destr=S2Q7_l0c1;
	pjob_destr=S2Q7_l0c1/S6Q1_l0c1;
	size=S6Q1_l0c1;
run;

proc means data=cam0 SUM MEAN; var S2Q7_l0c1 S2Q7_l0c5; weight poids_final; run;

proc freq data=cam0; tables extern deloc_b s2q3 deloc_b*s2q3 ; weight poids_final; run;

proc freq data=cam0; tables extern deloc_b s2q3; weight poids_final; run;
proc means data=cam0; var poids_final; class strate_eff; run;
proc means data=cam0; var job_destr pjob_destr; class deloc_b; run;


proc export data=cam0 (keep= firm poids_final extern deloc_b s2q3 job_destr pjob_destr
S2Q2_l1c1  S2Q2_l2c1  S2Q2_l3c1  S2Q2_l4c1  S2Q2_l5c1  S2Q2_l6c1  S2Q2_l7c1
S2Q2_l1c2  S2Q2_l2c2  S2Q2_l3c2  S2Q2_l4c2  S2Q2_l5c2  S2Q2_l6c2  S2Q2_l7c2 size) 
OUTFILE= "C:\Users\Public\Documents\Results\AKM\cam.dta" replace; run;
